<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/doorstore_style.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.4.4.min.js" ></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/table.js" ></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/cn-maszy-allen-time-1.0.js" ></script>
<script type="text/javascript">
	$(document).ready(function(){		
		setTime('#nowtime','{YYYY年MM月dd日  HH时mm分ss秒 星期week}',1000);
		$("#t2").hide();
		$("#ToGoodType").change(function(){
			var id=$(this).attr("value");
			if(id==1){
				$("#t2").hide();
				$("#t1").show();			
			}else if(id==2){
				$("#t1").hide();
				$("#t2").show();
			}
			$("#GoodPlan_Type").attr("value",id);
		})
		$("#DoorStore").change(function(){
			$("#Doortore_Id").attr("value",$(this).attr("value"));
		})
		$("#btn").click(function(){			
			var form=document.form;
			if(form.DoorStore_Id.value==0){
				alert("请选择门店");
				$("#DoorStore").focus();
				return false;
			}
			if(form.GoodPlan_Type.value==0){
				alert("请选择单据类型");
				$("#ToGoodType").focus();
				return false;
			}
			
			if(form.GoodPlan_Type.value==1){
				var b=false;
				$(".quantity").each(function(){  
					if($(this).val()!=0){
						b=true;
						return false;
					}  
				})  
			 	if(b==false){
					alert("早点要货单中必须至少填写一个单品的数量.");
					return false;
				}else{
					if(confirm("确认提交早点要货单吗?")){
						form.submit();
					}else{
						return false;
					}
					
				}
			}
			if(form.GoodPlan_Type.value==2){
				var c=false;
				$(".quantity2").each(function(){  
					if($(this).val()!=0){
						b=true;
						return false;
					}  
				});  
			 	if(c==false){
					alert("补货单中必须至少填写一个单品的数量.");
					return false;
				}else{
					if(confirm("确认提交补货单吗?")){
						form.submit();
					}else{
						return false;
					}
				}
			}

			
		})
	})

	</script>
<title>夏和餐饮要货管理系统</title>
</head>
<body>
<div id="top">
  <div class="logo"><img src="<%=request.getContextPath()%>/images/bg/doorstore/logo.gif" /></div>
</div>
<div id="main">
  <div class="top">
    <table style="width:100%;">
      <tr>
        <td style="width:20%">门店：
         					<select name="DoorStore_Id" id="DoorStore">
							<option value="0">
								==请选择==
							</option>
								<c:forEach items="${list}" var="item" varStatus="var">									
									<c:choose>
								<c:when test="${m.doorStore_Id==item.doorStore_Id}">				
									<option value="${item.doorStore_Id }" selected="selected">
											${item.doorStore_Name }
									</option>	
								</c:when>
								<c:otherwise>
									<option value="${item.doorStore_Id }">
											${item.doorStore_Name }
									</option>	
								</c:otherwise>
							</c:choose>		
							</c:forEach>
						</select></td>
        <td style="width:10%">填表人：
          ${m.staff_Name }</td>
          <td style="width:20%">单据类型：
          <select name="ToGoodType" id="ToGoodType">
          	<option value="0">
				==请选择==
			</option>
			<option value="1" selected="selected">
				早点要货单
			</option>
			<option value="2">
				补货单
			</option>
          </select>
          </td>
        <td style="width:30%">时间：
          <span id="nowtime" ></span></td>
      </tr>
    </table>
  </div>
  <form name="form" action="<%=request.getContextPath()%>/background/goodplan?method=insert" method="post">
    <div class="text">
      <!--表格1-->
      <table id="t1">
        <tr class="herd">
          <th style="width:10%;">序号</th>
          <th style="width:40%;">名称</th>
          <th style="width:10%;">数量</th>
           <th style="width:10%;">单位</th>
          <th style="width:30%;">说明</th>
        </tr>
        <c:forEach items="${proList}" var="item" varStatus="var">
        <tr>
          <td>${var.count }<input type="hidden" name="id" value="${item.product_Id}" /></td>
          <td>${item.product_Name}<input type="hidden" name="name" value="${item.product_Name}" /></td>
          <td><input type="text" name="quantity" class="quantity"  onkeyup="this.value=this.value.replace(/[^0-9]/g,'');"/></td>
            <td>${item.product_Unit}<input type="hidden" name="unit" value="${item.product_Unit}" /></td>
           <td>${item.product_Remark}</td>
        </tr>
        </c:forEach>
      </table>
      <!--表格2-->
      <table id="t2">
        <tr class="herd">
          <th style="width:10%;">序号</th>
          <th style="width:40%;">名称</th>
            <th style="width:10%;">数量</th>
          <th style="width:10%;">单位</th>        
          <th style="width:30%;">说明</th>
        </tr>
        <c:forEach var="i" begin="1" end="20" step="1"> 
        <tr>
          <td>${i}</td>
          <td><input type="text" name="PlanBody_Name"/></td>
          <td><input type="text" name="PlanBody_Quantity" class="quantity2"  onkeyup="this.value=this.value.replace(/[^0-9]/g,'');"/></td>
          <td><input type="text" name="PlanBody_Unit"/></td>
          <td><input type="text" name="PlanBody_Remark"/></td>
        </tr>
        </c:forEach>
       
      </table>
    </div>
    <div class="foot">
   		<input type="hidden" name="GoodPlan_Type" id="GoodPlan_Type" value="1"/>
   		<input type="hidden" name="GoodPlan_User" value="${m.staff_Name }"/>
		<input type="hidden" name="DoorStore_Id" id="DoorStore_Id" value="${m.doorStore_Id }"/>
      <input type="button" id="btn" class="btn" value="提交"/>
      <input type="reset" class="btn" value="重置"/>
    </div>
  </form>
</div>
<div id="footer">技术支持 - <a href="http://maszy.cn">马鞍山市志业软件科技有限公司</a>&nbsp;服务热线:13855585327 束磊
</div>
</body>
</html>
